<?php
require_once dirname(__FILE__) . '/common.inc.php';
require_once dirname(__FILE__) . "/DbUtils.class.php";

header('Content-Type: text/plain');

$path = MiscUtils::getParam('f', NULL);
$name = MiscUtils::getParam('n', NULL);

if (!file_exists($path)) {
  echo 'File not found in hard drive';
  exit;
} else {
  $file = fopen($path, "r");
  Header("Content-type: application/octet-stream");
  Header("Accept-Ranges: bytes");
  Header("Accept-Length:" . filesize($path));
  Header("Content-Disposition: attachment; filename=\"" . $name . "\"");
  echo fread($file, filesize($path));
  fclose($file);
  exit;
}
?>